package oop.core.view;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;

import oop.core.item.Equipment;
import oop.core.item.EquippableItem;
import oop.core.item.EquippableItemPosition;

/**
 * Panel of the main frame that displays currently equipped items.
 *
 */
public class EquipmentPanel extends SizeablePanel {

	private static final Dimension SIZE = new Dimension(400, 200);
	private static final Point LOCATION = new Point(600, 600);
	
	private Equipment equipment;
	
	/**
	 * Constructor sets location and size
	 */
	public EquipmentPanel()
	{
		super(LOCATION, SIZE);
	}
	
	public void takeEquipment(Equipment equipment)
	{
		this.equipment = equipment;
	}
	
	/**
	 * paintComponent renders the panel
	 */
	protected void paintComponent(Graphics g)
	{
//		System.out.println("Painting EquipmentPanel");
		g.setColor(Color.ORANGE);
		g.fillRect(0, 0, SIZE.width, SIZE.height);
		
		for(int k=0; k<5; k++)
		{
			EquippableItem item = equipment.getItem(k);
			if(item == null)
				continue;
			
			int x = 10 + (k%5)*50;
			int y = 10 + (k/5)*50;
			g.drawImage(ImageHandler.getImage(item.getImageID()), x, y, null);
		}
	}
}
